package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.game.item.ItemInfo;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class TurnTableInfoResponse extends Response {

	private int freeNum; // 免费次数
	private int pos; // 当前位置
	private int gold; // 消耗现金
	private List<Prize> prizes; // 奖品列表
	
	public static class Prize {
		private int id;
		private int count;
		private String name = "";
		private String icon = "";
		private String desc = "";
		public int getId() {
			return id;
		}
		public void setId(int id) {
			this.id = id;
		}
		public int getCount() {
			return count;
		}
		public void setCount(int count) {
			this.count = count;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getIcon() {
			return icon;
		}
		public void setIcon(String icon) {
			this.icon = icon;
		}
		public String getDesc() {
			return desc;
		}
		public void setDesc(String desc) {
			this.desc = desc;
		}
	}
	
	public TurnTableInfoResponse(int serial, int freeNum, int pos, int gold, List<ItemInfo> prizes) {
		super(serial);
		this.freeNum = freeNum;
		this.pos = pos;
		this.gold = freeNum > 0 ? 0 : gold;
		this.prizes = new ArrayList<Prize>(prizes.size());
		for (int i = 0; i < prizes.size(); i++) {
			ItemInfo ref = prizes.get(i);
			Prize p = new Prize();
			p.count = ref.getCount();
			if (ref.getCount() > 0) {
				p.id = ref.getId();
				p.name = ref.getTemplate().getName();
				p.icon = ref.getTemplate().getIcon();
				p.desc = ref.getTemplate().getDesc();
			}
			this.prizes.add(p);
		}
	}

	public int getFreeNum() {
		return freeNum;
	}

	public void setFreeNum(int freeNum) {
		this.freeNum = freeNum;
	}

	public int getPos() {
		return pos;
	}

	public void setPos(int pos) {
		this.pos = pos;
	}

	public int getGold() {
		return gold;
	}

	public void setGold(int gold) {
		this.gold = gold;
	}

	public List<Prize> getPrizes() {
		return prizes;
	}

	public void setPrizes(List<Prize> prizes) {
		this.prizes = prizes;
	}

}
